










module main(

	input			clk,
	input			rst,
	
	//an430
	output		VGA_CLK,
	output		VGA_EN,
	output		H_SYNC,
	output		V_SYNC,
	output [23:0]	VGA_Data,
	
	
	input			KeyLeft,
	input			KeyRight,
	input			KeyChange
);

wire vga_clk;


wire[8:0]	x_addr;
wire[8:0]	y_addr;
wire[23:0]	data;



wire    LeftDown;
wire    RightDown;
wire    ChangeDown;


//generate vga display clock 9M
Pll_9M Pll_9M_HP(
	
	.inclk0 		(clk),
	.c0			(vga_clk)
);



//teris game top
TetrisTop    TetrisTop_HP(
	
	.clk		(vga_clk),
	.rst		(rst),

	.KeyLeft	(LeftDown),
	.KeyRight	(RightDown),
	.KeyChange	(ChangeDown),
	
	//input current display position
	.x_addr	(x_addr),
	.y_addr	(y_addr),
	//output current display data
	.odata	(data)
);




//vga driver  output vga display
VGA_Driver   VGA_Driver_HP(

	.clk			(clk),
	.vga_clk		(vga_clk),
	.rst			(rst),
	//坐标输出
	.x_addr		(x_addr),		//水平坐标
	.y_addr		(y_addr),		//竖直坐标
	//显示数据输入
	.idata		(data),
	//VGA	
	.VGA_CLK		(VGA_CLK),		
	.VGA_EN		(VGA_EN),
	.H_SYNC		(H_SYNC),		//行同步时序
	.V_SYNC		(V_SYNC),		//列同步时序
	.VGA_Data		(VGA_Data) 	//VGA数据	
);



btn_dis_shake #(
	.mode(0)
)btn_dis_shake_HP1(
			
			.clk		(vga_clk),
			.rst_n	(rst),
			
			
			.ikey		(KeyLeft),				//按键输入
			.okey		(LeftDown)			//按键输出
);

btn_dis_shake #(
	.mode(0)
)btn_dis_shake_HP2(
			
			.clk		(vga_clk),
			.rst_n	(rst),
			
			
			.ikey		(KeyRight),				//按键输入
			.okey		(RightDown)			//按键输出
);


btn_dis_shake #(
	.mode(0)
)btn_dis_shake_HP3(
			
			.clk		(vga_clk),
			.rst_n	(rst),
			
			
			.ikey		(KeyChange),				//按键输入
			.okey		(ChangeDown)			//按键输出
);


endmodule 